home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
161_01
/
104.c
< prev
next >
Wrap
C/C++ Source or Header
|
1985-08-28
|
342b
|
26 lines
#include "timer1.h"
char c = 'c';
DO_IEXPR("Bit Count V2") bitcnt(c) OD
}
/* bitcnt - return the bit sum of a byte argument
* version 2
*/
#define BYTEMASK 0377
int bitcnt(c)
char c;
{
int b;
unsigned uc;
uc = c & BYTEMASK;
b = 0;
while (uc != 0)
{
if (uc & 01)
++b;
uc >>= 1;
}
return (b);
}